package com.igeek.oop.pojo;

import com.igeek.oop.dao.Info;

/**
 * 电脑终端
 */
public class Computer {

    /**
     * 存储用户信息，放到数组中存储
     */
    private final static Info[] infos = new Info[100];

    /**
     * 记录当前用户信息数组，存储的索引位置
     */
    private static int count = 0;

    static {
        //初始化信息
        infos[0] = new Info("admin","123","");
        infos[1] = new Info("zhangsan","123","");
        infos[2] = new Info("lisi","123","");

        count = 2;
    }

    public void insertInfo(Info info){
        count++;
        infos[count] = info;

    }

    /**
     * 校验用户信息
     * @param info
     */
    public boolean checkInfo(Info info){

        for(int i = 0;i<count;i++){

            //需要稍后处理：有了密码就需要验证指纹，有了指纹就不需要验证密码
            if(info.getUsername().equals(infos[i].getUsername()) &&
                info.getPassword().equals(infos[i].getPassword()) ){

                System.out.println("校验通过");
                return true;
            }else{

                System.out.println("校验不通过");
                return false;
            }
        }
        return false;
    }
}
